from time import time
t0=time()

LIMIT=10**2

def primes(n):
    p = [1] * (n/2)
    for i in xrange(3, int(n**0.5)+1, 2):
        if p[i/2]:            
            p[i*i/2::i] = [0] * ((n-i*i-1)/(2*i)+1)
    return [2] + [2*i+1 for i in xrange(1,n/2) if p[i]]

def allPrime(maxNum):
    aList = range(0, maxNum)
    def _do(aPrime):
        for i in xrange(aPrime, maxNum, aPrime):
            aList[i] = 0
        return aPrime
    return map(_do,
        (i for i in xrange(2,maxNum) if aList[i])
        )
        
print  primes(LIMIT)
#print len( allPrime(LIMIT) )

print (time()-t0)

'''
primes:
664579
1.07299995422

allPrime:
664579
8.51099991798

'''
